package com.itheima.easy.listen;

import com.alibaba.fastjson.JSON;
import com.itheima.easy.mq.MqMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import java.io.IOException;

/**
 * 监听消息，同步支付状态
 */
@Slf4j
@Component
@RabbitListener(queues = "trade-queue-sky")
public class TradeListen {
    @RabbitHandler
    public void onMessage(String message) throws IOException {
        log.info("接收到消息：{}",message);

        MqMessage mqMessage = JSON.parseObject(message, MqMessage.class);

        //TODO 业务系统修改支付状态
    }
}
